package com.project.service.impl;


import com.base.entity.bo.ExpertBo;
import com.base.entity.vo.ExpertVo;
import com.base.service.ExpertService;
import com.base.utils.CutPageBean;
import com.common.utils.SecurityUtils;
import com.common.utils.uuid.IdUtils;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.framework.handler.MyMetaObjectHandler;
import com.project.comom.NumberDealUtils;
import com.project.domain.dto.projectApplyDto.ExportApplyBookMybatisDto;
import com.project.domain.dto.projectReviewDto.*;
import com.project.domain.entity.BizExpertReview;
import com.project.domain.entity.BizReviewResult;
import com.project.domain.entity.BizReviewScheme;
import com.project.domain.entity.BizReviewStandard;
import com.project.domain.vo.BizProjectApplyInfoVo;
import com.project.domain.vo.BizReviewSchemeVo4EditPage;
import com.project.mapper.ProjectReviewMapper;
import com.project.service.IProjectReviewService;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

import static com.project.comom.DateDealUtils.castInputDateStrToRequireFormat;

/**
 * Created by cw13031 on 2025/2/6.
 * Description:
 */
@Service
public class ProjectReviewServiceImpl implements IProjectReviewService {

    @Autowired
    ProjectReviewMapper projectReviewMapper;

    @Autowired
    private MyMetaObjectHandler autoFillFieldsHandler;

    @Autowired
    ExpertService expertService;

    @Override
    public List<BizReviewScheme> schemeList() {
        return projectReviewMapper.schemeList();
    }

    @Override
    public HashMap<String,Object> getScheme(BizReviewScheme bizReviewScheme) {
        BizReviewScheme scheme = projectReviewMapper.getSchemeInfo(bizReviewScheme);
        if (scheme!=null){
            HashMap<String,Object> x = new HashMap<>();
            x.put("name",scheme.getName());
            x.put("fullMark",scheme.getFullMark());
            ArrayList<HashMap<String,Object>> objects = buildReviewSchemeChildren(bizReviewScheme);
            x.put("items",objects);
            return x;
        }else {
            return null;
        }

    }




    private ArrayList<HashMap<String,Object>> buildReviewSchemeChildren(BizReviewScheme bizReviewScheme){
        ArrayList<BizReviewStandard> items =  projectReviewMapper.getSchemeStandard(bizReviewScheme);
        ArrayList<HashMap<String,Object>> itemsList = new ArrayList<>();
        for (BizReviewStandard t :items) {
            HashMap<String, Object> map = new HashMap<>();
            String l1Name = t.getName();
            BigDecimal standardMark = t.getStandardMark();
            String Lvl2Names = t.getLvl2Names();
            String Lvl2Marks = t.getLvl2Marks();
            Integer orderId = t.getOrderId();
            map.put("lv1name",l1Name);
            map.put("lv1mark",standardMark);
            map.put("orderId",orderId);
            ArrayList<Map<String, String>> lv2Items = jsonToArrayList(Lvl2Names);

            ArrayList<HashMap<String, Object>> lv2MapList = new ArrayList<>();
            if (lv2Items == null){
                HashMap<String, Object> lv2Map = new HashMap<>();
                lv2Map.put("lv2name",Lvl2Names);
                lv2Map.put("lv2mark",Lvl2Marks);
                lv2MapList.add(lv2Map);
                map.put("lv2",lv2MapList);
            }else {
                for (int i = 0; i < lv2Items.size(); i++) {
                    HashMap<String, Object> lv2Map = new HashMap<>();
                    lv2Map.put("lv2name",lv2Items.get(i).get("value"));
                    lv2Map.put("lv2mark",Lvl2Marks.split(",")[i]);
                    lv2MapList.add(lv2Map);
                    map.put("lv2",lv2MapList);
                }
            }
            itemsList.add(map);
        }
        return itemsList;

    }

    private static final ObjectMapper objectMapper = new ObjectMapper();


    // 将 JSON 字符串转换为 ArrayList<Map<String, String>>
    public static ArrayList<Map<String, String>> jsonToArrayList(String jsonStr) {
        try {
            // 使用 TypeReference 来传递泛型类型
            return objectMapper.readValue(jsonStr, new TypeReference<ArrayList<Map<String, String>>>() {});
        } catch (Exception e) {
//            e.printStackTrace();
            return null; // 转换失败返回 null
        }
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveScheme(BizReviewSchemeVo4EditPage bizReviewSchemeVo4EditPage) {

        if (!StringUtils.hasText(bizReviewSchemeVo4EditPage.getId())){
            // 数据 插入时 自动记录的字段
            MetaObject metaObject = MyMetaObjectHandler.getMetaObject(bizReviewSchemeVo4EditPage);
            autoFillFieldsHandler.fillForInsert(metaObject);
            //生成主键id
            String uuid = IdUtils.simpleUUID();
            bizReviewSchemeVo4EditPage.setId(uuid);

            projectReviewMapper.insertScheme(bizReviewSchemeVo4EditPage);

            // 将前端格式化数据，转为反人类的后端期望格式,为插入评审方案标准表做准备
            bizReviewSchemeVo4EditPage.argsToDbFormat();

            projectReviewMapper.insertSchemeStandard(bizReviewSchemeVo4EditPage);
        }else {
            // 数据 更新时 自动记录的字段
            MetaObject metaObject = MyMetaObjectHandler.getMetaObject(bizReviewSchemeVo4EditPage);
            // 本来该用fillForUpdate的，但是附表存在清空再插入的操作，这里用fillForInsert更简单，也不影响效果
            autoFillFieldsHandler.fillForInsert(metaObject);
            // 更新 评审方案主表信息
            int rows = projectReviewMapper.updateScheme(bizReviewSchemeVo4EditPage);
            if (rows==0){
                return;
            }
            // 将前端格式化数据，转为反人类的后端期望格式,为插入评审方案标准表做准备
            bizReviewSchemeVo4EditPage.argsToDbFormat();
            ArrayList<String> idList = new ArrayList<>();
            idList.add(bizReviewSchemeVo4EditPage.getId());
            projectReviewMapper.deleteSchemeStandard(idList);
            projectReviewMapper.insertSchemeStandard(bizReviewSchemeVo4EditPage);
        }
    }

    /**
     * 由于有外键约束，因此应该先删除Standard中的数据
     * @param ids 评审方案id列表
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delScheme(List<String> ids) {
        projectReviewMapper.deleteSchemeStandard(ids);
        projectReviewMapper.delScheme(ids);
    }

    @Override
    public List<HashMap<String, Object>> planList(PlanListDto dto) {
        changeInputDateFormat(dto);
        return projectReviewMapper.planList(dto);
    }

    @Override
    public List<HashMap<String, Integer>> planListStatistics(PlanListDto dto) {
        changeInputDateFormat(dto);
        return projectReviewMapper.planListStatistics(dto);
    }

    @Override
    public int planState(PlanStateDto dto) {
        return projectReviewMapper.planState(dto);
    }

    @Override
    public int planDel(ArrayList<String> idList) {
        return projectReviewMapper.planDel(idList);
    }

    @Override
    public List<HashMap<String, Object>> passedBooks(PassedBooksReqDto dto) {
        List<HashMap<String, Object>> hashMaps = projectReviewMapper.passedBooks(dto);
        buildExpertObj(hashMaps);
        return hashMaps;
    }

    @Override
    public List<HashMap<String, Object>> lixiangList(LixiangListReqDto dto) {
        List<HashMap<String, Object>> hashMaps = projectReviewMapper.lixiangList(dto);
        buildExpertObj(hashMaps);
        return hashMaps;
    }

    @Override
    public ArrayList<AssignExpertSingleLineDto> assignExperts(ArrayList<String> bookIdList) {
        ArrayList<AssignExpertSingleLineDto> AssignExpertSingleLineDtoList = projectReviewMapper.assignExperts(bookIdList);
        //构造expert 字段，用于前端显示 已分配专家列表
//        buildExpertObjExpertReviewIds(hashMaps);
        //构造allExpert 字段，用于前端显示 所有专家列表
        addAllExpertField(AssignExpertSingleLineDtoList);
        return AssignExpertSingleLineDtoList;
    }

    /**
     * 保存专家时，前端只传来了最终保留的专家。
     * 因此需要查询原有专家，然后对比新旧列表，新增的插入到BIZ_EXPERT_REVIEW中
     * @param dtoList
     * @return
     */
    @Override
    public int saveExperts(List<SaveExpertsReqDto> dtoList) {
        //region 查询所有给定book的所有专家评审id
        List<BizExpertReview> oldExpertReviewList = projectReviewMapper.getExpertReviewIdByBookIdList(dtoList);
        ArrayList<String> oldExpertReviewIdList = new ArrayList<>();
        for (BizExpertReview hashMap : oldExpertReviewList) {
            oldExpertReviewIdList.add(hashMap.getId());
        }
        //endregion

        //region 从入参提取所有的专家评审id
        ArrayList<HashMap<String,String>> newExpertReviewList = new ArrayList<>();

        for (SaveExpertsReqDto dto : dtoList) {
            String bookId = dto.getBookId();
            ArrayList<HashMap<String, String>> expertsList = dto.getExpertsList();

            expertsList.forEach(expert -> {
                expert.put("bookId", bookId);
            });

            newExpertReviewList.addAll(expertsList);
        }

        //endregion


//        ArrayList<HashMap<String, String>> needToDelete = new ArrayList<>();
        ArrayList<HashMap<String, String>> needToAdd = new ArrayList<>();

        //region 没有评审id：新加的专家
        for (HashMap<String, String> newExpertReview : newExpertReviewList) {
            if (newExpertReview.get("expertReviewId")==null || "".equals(newExpertReview.get("expertReviewId"))){
                needToAdd.add(newExpertReview);
            }
        }
        //endregion

        //region 遍历旧的评审id，找出依然存在的评审id
        ArrayList<String> unmodifiedExpertReviewIdList = new ArrayList<>();
        for (String expertReviewId : oldExpertReviewIdList) {
            for (HashMap<String, String> stringStringHashMap : newExpertReviewList) {
                if (stringStringHashMap.get("expertReviewId")!=null && expertReviewId.equals(stringStringHashMap.get("expertReviewId"))){
                    unmodifiedExpertReviewIdList.add(expertReviewId);
                }
            }
        }
        //endregion

        //region 比较新旧评审id，找出需要删除的评审id
        List<String> needToDelete = oldExpertReviewIdList.stream()
                .filter(item -> !unmodifiedExpertReviewIdList.contains(item))
                .collect(Collectors.toList());
        //endregion

        //region 按需删除
        if (!needToDelete.isEmpty()){
            projectReviewMapper.deleteExpertReviewById(needToDelete);
            projectReviewMapper.deleteExpertReviewDetailById(needToDelete);
        }
        //endregion

        //region 按需新增
        if (!needToAdd.isEmpty()){
            ArrayList<BizExpertReview> bizExpertReviews = genExpertReviewRows(needToAdd);
            projectReviewMapper.saveExperts(bizExpertReviews);
        }
        //endregion
        return 0;
    }

    @Override
    public List<HashMap<String, Object>> infoExperts(InfoExpertsReqDto dto) {
        return projectReviewMapper.infoExperts(dto);
    }

    @Override
    public List<HashMap<String, Object>> reviewPros(ReviewProsDto dto) {
        return projectReviewMapper.reviewPros(dto);
    }

    @Override
    public int makeMessage(MakeMsgReqDto dto) {
//        String uuid = IdUtil.randomUUID().replace("-", "");
//        dto.setId(uuid);
        return projectReviewMapper.makeMessage(dto);
    }

    @Override
    public List<HashMap<String, Object>> myReviews(MyReviewReqDto dto) {
        String string = SecurityUtils.getLoginUser().getUser().getUserRealId();
        dto.setSysUserId(string);
        List<HashMap<String, Object>> hashMaps = projectReviewMapper.myReviews(dto);
        //region 元-->万元
        NumberDealUtils.mapListYuan2Wan(hashMaps,"applyFee");
        //endregion
        return hashMaps;
    }

    /**
     * 专家评审页面数据
     * @param bookId bookId
     * @return x
     */
    @Override
    public ExpertOptionsResDto opinionSummary(String bookId) {

        ArrayList<ExpertOptionsMybatisDto> expertOptionsDtoList = projectReviewMapper.getOpinionSummaryByBookId(bookId);

        ArrayList<ExpertOptionsDto> expertOptionsDtos = genExpertOptionDto(expertOptionsDtoList);
        AdminOptionsDto adminOptionsDto =  projectReviewMapper.getAdminReview(bookId);

        ExpertOptionsResDto expertOptionsResDto = new ExpertOptionsResDto();
        expertOptionsResDto.setExpertOptionsList(expertOptionsDtos);
        expertOptionsResDto.setAdminOptionsDto(adminOptionsDto);
        expertOptionsResDto.setRemakeDetail(expertOptionsDtoList);

        return expertOptionsResDto;
    }

    @Override
    public int updateOpinionSummary(SaveAdminReviewOptionReqDto dto) {
        return projectReviewMapper.updateOpinionSummary(dto);
    }

    @Override
    public ArrayList<ExportApplyBookMybatisDto> exportExcel(PassedBooksExcelReqDto dto) {
        return projectReviewMapper.exportExcel(dto);
    }

    @Override
    public int refuseReview(RefuseReviewDto dto) {
        return projectReviewMapper.refuseReview(dto);
    }

    @Override
    public int submit(ExpertSubmitDto dto) {
        return projectReviewMapper.submit(dto);
    }

    @Override
    public ViewExpertReviewResDto reviewDetails(ViewExpertReviewDetailsReqDto dto) {
        ArrayList<ViewExpertReviewJoinTableFormatDto> mybatisData = projectReviewMapper.reviewDetails(dto);

        ViewExpertReviewResDto res = ReviewDetailsResDto.fromMybatisToResFormat(mybatisData);

        ViewExpertReviewResMainDto expertReviewOtherFields = getExpertReviewOtherFields(dto);
        res.setReviewObjectName(expertReviewOtherFields.getReviewObjectName());
        res.setApplyFile(expertReviewOtherFields.getApplyFile());
        res.setPlanFile(expertReviewOtherFields.getPlanFile());
        res.setExpertReviewId(expertReviewOtherFields.getExpertReviewId());
        res.setReviewInfo(expertReviewOtherFields.getReviewInfo());
        res.setReviewResult(expertReviewOtherFields.getReviewResult());
        return res;
    }

    /**
     * 评审人员进行评审
     * @param dto x
     * @return x
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public Boolean SaveReviewDetails(SaveExpertReviewReqDto dto) {
        //①先删除原有评审结果
        int i1 = deleteReviewResult(dto.getExpertReviewId());
        //②再插入新的评审结果
        ArrayList<BizReviewResult> x = ReviewDetailsResDto.fromReqFormatToMybatis(dto);
        int i2 = insertReviewResult(x);
        //③更新expertReview表的信息
        //计算评审结果总分数
        BigDecimal reviewMark = BigDecimal.ZERO;
        for (BizReviewResult o :x) {
            BigDecimal reviewMark1 = o.getReviewMark();
            reviewMark = reviewMark.add(reviewMark1);  // 使用 add 方法进行累加
        }
        dto.setReviewMark(reviewMark);
        int i3 = updateExpertReview(dto);
        return true;
    }

    ArrayList<BizExpertReview> genExpertReviewRows(List<SaveExpertsReqDto> dtoList){
        ArrayList<BizExpertReview> bizExpertReviews = new ArrayList<>();
        for (SaveExpertsReqDto o :dtoList) {

            BizExpertReview basicFieldsByBookId = getBasicFieldsByBookId(o);
            for (HashMap<String,String> map :o.getExpertsList()) {
                BizExpertReview bizExpertReview = new BizExpertReview();
                // 数据 插入时 自动记录的字段
                MetaObject metaObject = MyMetaObjectHandler.getMetaObject(bizExpertReview);
                autoFillFieldsHandler.fillForInsert(metaObject);

                String name = map.get("name");
                String id = map.get("id");
                bizExpertReview.setReviewerId(id);
                bizExpertReview.setReviewerName(name);
                bizExpertReview.setReviewPlanId(basicFieldsByBookId.getReviewPlanId());
                bizExpertReview.setReviewObjectId(basicFieldsByBookId.getReviewObjectId());
                bizExpertReview.setReviewObjectName(basicFieldsByBookId.getReviewObjectName());
                bizExpertReview.setReviewSchemeId(basicFieldsByBookId.getReviewSchemeId());
                bizExpertReviews.add(bizExpertReview);
            }
        }
        return bizExpertReviews;
    }

    ArrayList<BizExpertReview> genExpertReviewRows(ArrayList<HashMap<String,String>> needToAdd){
        ArrayList<BizExpertReview> bizExpertReviews = new ArrayList<>();
        for (HashMap<String,String> map :needToAdd) {
            BizExpertReview basicFieldsByBookId = projectReviewMapper.getBasicFieldsByBookId(map.get("bookId"));

            BizExpertReview bizExpertReview = new BizExpertReview();
            // 数据 插入时 自动记录的字段
            MetaObject metaObject = MyMetaObjectHandler.getMetaObject(bizExpertReview);
            autoFillFieldsHandler.fillForInsert(metaObject);

            String name = map.get("name");
            String id = map.get("id");
            bizExpertReview.setReviewerId(id);
            bizExpertReview.setReviewerName(name);
            bizExpertReview.setReviewPlanId(basicFieldsByBookId.getReviewPlanId());
            bizExpertReview.setReviewObjectId(basicFieldsByBookId.getReviewObjectId());
            bizExpertReview.setReviewObjectName(basicFieldsByBookId.getReviewObjectName());
            bizExpertReview.setReviewSchemeId(basicFieldsByBookId.getReviewSchemeId());
            bizExpertReviews.add(bizExpertReview);

        }
        return bizExpertReviews;
    }

    /**
     * 使用查询得到的字段，合成适合前端使用的额外字段
     * @param hashMaps x
     */
    private void buildExpertObj(List<HashMap<String, Object>> hashMaps){
        for (HashMap<String, Object> o :hashMaps) {
            if (o.get("reviewerIds")==null){
                o.put("expert",null);
                continue;
            }
            String expertIds = o.get("reviewerIds").toString();
            String expertNames = o.get("reviewerNames").toString();
            ArrayList<HashMap<String, String>> hashMaps1 = new ArrayList<>();

            for (int i = 0; i < expertIds.split(",").length; i++) {
                HashMap<String, String> t = new HashMap<>();
                t.put("name",expertNames.split(",")[i]);
                t.put("id",expertIds.split(",")[i]);
                hashMaps1.add(t);
            }
            o.put("expert",hashMaps1);
        }
    }

    /**
     * 将所有专家列表查出来，添加到每一行数据中
     * @deprecated 该方法已被废弃
     * @param hashMaps x
     */
    public void addExpert(List<HashMap<String, Object>> hashMaps){
        ExpertVo expertVo = new ExpertVo();
        expertVo.setPage(1);
        expertVo.setPageSize(200);
        CutPageBean<ExpertBo> expertBoCutPageBean = expertService.selectExpertList(expertVo);
        List<ExpertBo> list = expertBoCutPageBean.getList();
        ArrayList<HashMap<String, String>> allExpert = new ArrayList<>();

        for (ExpertBo expertBo :list) {
            HashMap<String, String> t = new HashMap<>();
            t.put("name",expertBo.getName());
            t.put("id",expertBo.getId());
            allExpert.add(t);
        }

        for (HashMap<String, Object> t :hashMaps) {
            t.put("allExpert",allExpert);
        }
    }


    public void addAllExpertField(ArrayList<AssignExpertSingleLineDto> list){
        //region 查询得到所有专家
        ExpertVo expertVo = new ExpertVo();
        expertVo.setPage(1);
        expertVo.setPageSize(2000);
        CutPageBean<ExpertBo> expertBoCutPageBean = expertService.selectExpertList(expertVo);
        List<ExpertBo> allExpertList = expertBoCutPageBean.getList();
        //endregion

        for (AssignExpertSingleLineDto assignExpertSingleLineDto : list) {
            ArrayList<String> expertIds = new ArrayList<>(Arrays.asList(assignExpertSingleLineDto.getReviewerIds().split(",")));
            ArrayList<String> expertReviewIds = new ArrayList<>(Arrays.asList(assignExpertSingleLineDto.getExpertReviewIds().split(",")));

            ArrayList<AssignExpertSingleLineAllExpertDto> expertList = new ArrayList<>();
            for (ExpertBo expertBo :allExpertList) {
                AssignExpertSingleLineAllExpertDto expertDto = new AssignExpertSingleLineAllExpertDto();
                expertDto.setId(expertBo.getId());
                expertDto.setName(expertBo.getName());
                expertDto.setPersonId(expertBo.getPersonId());

                int index = expertIds.indexOf(expertBo.getId());

                if (index!=-1){
                    expertDto.setExpertReviewId(expertReviewIds.get(index));
                }else {
                    expertDto.setExpertReviewId("");
                }
                expertList.add(expertDto);
            }
            assignExpertSingleLineDto.setAllExpert(expertList);
        }
    }



//    public BizReviewPlan getPlanByBookId(String bookId){
//        return projectReviewMapper.getPlanByBookId(bookId);
//    }

    public BizExpertReview getBasicFieldsByBookId(SaveExpertsReqDto dto){

        return projectReviewMapper.getBasicFieldsByBookId(dto.getBookId());
    }

    /**
     * 专家评审页面，除了评审项目的其他字段
     * @param dto 通过expertReviewId获取
     * @return
     */
    public ViewExpertReviewResMainDto getExpertReviewOtherFields(ViewExpertReviewDetailsReqDto dto){

        return projectReviewMapper.getExpertReviewOtherFields(dto);
    }

    /**
     * 根据expertReviewId删除评审结果
     * @param expertReviewId 专家评审id
     * @return x
     */
    public int deleteReviewResult(String expertReviewId){
        return projectReviewMapper.deleteReviewResult(expertReviewId);
    }

    /**
     * 插入详细的评审结果条目
     * @param bizReviewResultList 前端数据
     * @return x
     */
    public int insertReviewResult(ArrayList<BizReviewResult> bizReviewResultList){
        for (BizReviewResult o :bizReviewResultList) {
            // 数据 插入时 自动记录的字段
            MetaObject metaObject = MyMetaObjectHandler.getMetaObject(o);
            autoFillFieldsHandler.fillForInsert(metaObject);
        }
        return projectReviewMapper.insertReviewResult(bizReviewResultList);
    }

    /**
     * 更新biz_expert_review中的 评审意见 评审结果 保存状态
     * @param dto
     * @return
     */
    public int updateExpertReview(SaveExpertReviewReqDto dto){
        BizExpertReview bizExpertReview = new BizExpertReview();
        bizExpertReview.setId(dto.getExpertReviewId());
        bizExpertReview.setReviewMark(dto.getReviewMark());
        bizExpertReview.setReviewInfo(dto.getReviewInfo());
        bizExpertReview.setReviewResult(dto.getReviewResult());
        bizExpertReview.setReviewStatus(dto.getReviewStatus());
        // 数据 插入时 自动记录的字段
        MetaObject metaObject = MyMetaObjectHandler.getMetaObject(bizExpertReview);
        autoFillFieldsHandler.fillForInsert(metaObject);

        return projectReviewMapper.updateExpertReview(bizExpertReview);
    }


    public ArrayList<ExpertOptionsDto> genExpertOptionDto(ArrayList<ExpertOptionsMybatisDto> expertOptionsDtoList){
        ArrayList<ExpertOptionsDto> list = new ArrayList<>();
        for (ExpertOptionsMybatisDto o :expertOptionsDtoList) {
            ExpertOptionsDto dto = new ExpertOptionsDto();
            dto.setReviewerName(o.getReviewerName());
            dto.setReviewerInfo(o.getReviewerInfo());
            dto.setReviewerResult(o.getReviewerResult());
            dto.setExpertStatus(o.getExpertStatus());
            list.add(dto);
        }
        return list;
    }

    void changeInputDateFormat(PlanListDto dto) {
        dto.setBeginDate1(castInputDateStrToRequireFormat(dto.getBeginDate1()));
        dto.setBeginDate2(castInputDateStrToRequireFormat(dto.getBeginDate2()));
        dto.setEndDate1(castInputDateStrToRequireFormat(dto.getEndDate1()));
        dto.setEndDate2(castInputDateStrToRequireFormat(dto.getEndDate2()));
    }
}
